home *** CD-ROM | disk | FTP | other *** search
- {$D+} {generate debug symbols}
- Program PatternScroller;
- {**** written and © 1989 by Shelly Mendlinger
- **** Brooklyn, New York}
-
- {$R PatList.RSRC} {identify res file}
- {$U-} {No defaults. We'll roll our own}
- uses
- memtypes,
- quickdraw,
- osintf,
- toolintf,
- packintf;
- const
- LdefNum = 1000;
- title = 'PatternScroller ©1989 by Shelly Mendlinger';
- var
- Rview,
- dBounds,
- Wrect,
- totRect,
- testRect : rect;
- cSize : point;
- theCell : cell;
- wind : windowPtr;
- theList : listHandle;
- thePat : pattern;
- index,
- dLen,
- theProc : integer;
- str : str255;
- event : eventRecord;
- aHand : handle;
- aCell : cell;
- over,
- bool,
- drawIt,
- hasGrow,
- scrollHoriz,
- scrollVert : boolean;
-
- Procedure ShowPat;
- begin
- {--- set vars ---}
- dLen := 8;
- setPt(theCell,0,0);
- {--- get current selection ---}
- bool := LGetSelect(true,theCell,theList);
- {--- get cell data ---}
- LGetCell(@thePat,dLen,theCell,theList);
- {--- show pat ---}
- fillrect(testRect,thePat);
- framerect(testrect);
- end;{proc show pat}
-
- Procedure Initialize;
- begin
- {--- Let the Games Begin ---}
- initGraf(@thePort);
- initFonts;
- initWindows;
- initCursor;
- {--- open a window ---}
- setrect(wRect,10,50,500,330);
- wind := newWindow(nil,wRect,title,true,0,pointer(-1),true,0);
- setPort(wind);
- flushEvents(everyevent,0);
- end;{proc init}
-
- Procedure SetUpList;
- begin
- {--- set parameters ---}
- setRect(Rview,100,20,340,50);{drawing area, local coords}
- setrect(dBounds,0,0,38,1);{38 long,1 high}
- setPt(cSize,30,30);{30X30 pixel cells}
- theProc := LDefNUm;{LDEF ID}
- drawIt := false; {turn off drawinf=g}
- hasgrow := false; {no grow box}
- scrollHoriz := true;{yes horiz scroll bar}
- scrollVert := false; {no vert scroll}
- {--- start things going ---}
- theList := LNew(Rview,dbounds,cSize,
- theProc,wind,drawIt,hasGrow,
- scrollHoriz,scrollVert);
- {--- fill cells with pat data ---}
- for index := 1 to 38 do
- begin
- setPt(theCell,index-1,0);
- getIndPattern(thePat,sysPatListID,index);
- LSetCell(@thePat,sizeof(pattern),theCell,theList);
- end;{for index}
- {--- draw the list ---}
- LDoDraw(true,theList);
- LUpdate(wind^.visRgn,theList);
- {--- select starting pat ---}
- setPt(theCell,3,0);
- LsetSelect(true,theCell,theList);
- totrect := Rview;
- totRect.bottom := totRect.bottom + 15; {include scroll rect}
- end;{proc Set up list}
-
- Procedure doTestRect;
- begin
- setRect(testrect,100,100,340,250);
- str:= 'Test Rect';
- with testRect do
- moveto(left+(right-left-stringWidth(str)) div 2,96);
- drawstring(str);
- Showpat;
- end;{proc do Test Rect}
-
- Procedure HandleEvent(evt : EventRecord);
- var
- aPt,
- pt2 : point;
- aRect,
- oldRect : rect;
- long : longint;
- begin
- aPt := evt.where;
- {--- what's happining? ---}
- case evt.what of
- keydown: over := true;{any key quits}
- mousedown: case findWindow(aPt,wind) of
- inGoAway: over := true;{say bye-bye}
- inContent: begin
- setRect(oldRect,0,0,0,0);
- globalToLocal(aPt);
- {--- is click in list? ---}
- if ptInRect(aPt,totRect) then
- begin
- {--- get current selection ---}
- setPt(theCell,0,0);
- bool := LGetSelect(true,aCell,theList);
- {--- deselect old cell ---}
- LSetSelect(false,aCell,theList);
- {--- trach click ---}
- bool := LClick(aPt,evt.modifiers,theLIst);
- {--- is click in a pattern ---}
- if ptInRect(aPt,Rview) then
- begin
- {--- get new cell ---}
- long := LLastclick(theList);
- aCell := cell(long);
- end;{in pat}
- {--- select/reselect cell ---}
- LSetSelect(true,aCell,theList);
- ShowPat;
- end;{in totRect}
- end;{inContent}
- otherwise
- end;{case findwindow}
- otherwise
- end;{case what}
- end;{proc handle event}
-
- BEGIN {main}
- Initialize;
- SetUpList;
- DoTestRect;
- {--- do event loop ---}
- over := false;
- repeat
- if getNextEvent(everyEvent,event) then
- handleEvent(event) ;
- until over;
- {--- clean up --}
- Ldispose(theList);
- end.{prog PatternScroller}
-
-
-
-
-
-
-
-
-